const webpack = require('webpack')
const path = require('path')
const os = require('os')
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')

const vendors = [
  'vue/dist/vue.common.js',
  'vuex',
  'vue-router',
  'element-ui',
  'vuex-router-sync'
]

module.exports = {
  output: {
    path: path.resolve(__dirname, 'src/assets'),
    filename: 'js/[name].js',
    library: '[name]',
    libraryTarget: "var"
  },
  entry: {
    "lib": vendors,
  },
  plugins: [
    new UglifyJSPlugin({
      exclude: /\.min\.js$/,
      parallel:  os.cpus().length,
      uglifyOptions: {
        ecma: 5,
        compress: {
          warnings: false,
          drop_console: true,
          drop_debugger: true
        }
      }
    }),
    new webpack.DllPlugin({
      path: 'manifest.json',
      name: '[name]',
      context: __dirname,
    }),
  ],
  mode: 'production'
}
